#include "vec.h"

Vec3 Vec3::CRSpline(const Vec3 &p0, const Vec3 &p1, const Vec3 &p2, const Vec3 &p3, float t)
{
	float t2 = t * t;
	float t3 = t2 * t;
	return Vec3(
		0.5f * ((2.0f*p1.x) + (-p0.x+p2.x)*t + (2.0f*p0.x - 5.0f*p1.x + 4*p2.x - p3.x)*t2 + (-p0.x + 3.0f*p1.x - 3.0f*p2.x + p3.x)*t3),
		0.5f * ((2.0f*p1.y) + (-p0.y+p2.y)*t + (2.0f*p0.y - 5.0f*p1.y + 4*p2.y - p3.y)*t2 + (-p0.y + 3.0f*p1.y - 3.0f*p2.y + p3.y)*t3),
		0.5f * ((2.0f*p1.z) + (-p0.z+p2.z)*t + (2.0f*p0.z - 5.0f*p1.z + 4*p2.z - p3.z)*t2 + (-p0.z + 3.0f*p1.z - 3.0f*p2.z + p3.z)*t3));
}

Vec2 Vec2::ZERO(0, 0);

Vec3 Vec3::ZERO(0, 0, 0);
Vec3 Vec3::XAXIS(1, 0, 0);
Vec3 Vec3::YAXIS(0, 1, 0);
Vec3 Vec3::ZAXIS(0, 0, 1);

Vec4 Vec4::ZERO(0, 0, 0, 0);